<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>水平垂直居中-table-cell方法，兼容IE6，7</title>
        <style>
            .table {
                height: 300px;/*高度值不能少*/
                width: 300px;/*宽度值不能少*/
                display: table;
                position: relative;
                float:left;
            }       

            .tableCell {
                display: table-cell;
                vertical-align: middle;
                text-align: center;         
                padding: 10px;
                *position: absolute;
                *top: 50%;
                *left: 50%;
            }
            .content {
                *position:relative;
                *top: -50%;
                *left: -50%;
            }
        </style>
    </head>
    <body>
        <h1>周刊5# 居中之美</h1>
        <p>来源:<a href="https://www.w3cplus.com/collective-5.html">https://www.w3cplus.com/collective-5.html</a></p>
        <div class="table">
            <div class="tableCell">
                <div class="content">content</div>
            </div>
        </div>
    </body>
</html>